import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:zootix/models/zt_user_info.model.dart';
import 'package:zootix/store/zt_auth.store.dart';
import 'package:zootix/apis/zt-api.dart' as Api;

class ZtUserInfoController extends GetxController {
  final nickNameController = TextEditingController(text: '');
  final countryController = TextEditingController(text: '');
  final birthdayController = TextEditingController();

  @override
  void onReady() async {
    nickNameController.text = ZtAuthStore.to.userInfo.value.nickname ?? '';
    birthdayController.text = ZtAuthStore.to.userInfo.value.birthday ?? '';
    countryController.text = ZtAuthStore.to.userInfo.value.country ?? '';
    super.onReady();
  }

  Future<void> saveUserInfo() async {
    Map<String, dynamic> data = {
      'nickname': nickNameController.text,
      'birthday': birthdayController.text,
      'country': countryController.text,
    };
    await ZtAuthStore.to.saveUserInfo(data);
  }
}
